//
//  ChartingTop4CollectionViewCell.m
//  intelligent
//
//  Created by 甘世清 on 2024/3/1.
//

#import "ChartingTop4CollectionViewCell.h"

@implementation ChartingTop4CollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.layer.masksToBounds = YES;
        [self SQ_UIViewForSelfView];
    }
    return self;
}
/// 添加ui
-(void)SQ_UIViewForSelfView
{
    self.contentView.backgroundColor = SQColor(@"#DFF8EF");
    self.layer.cornerRadius = 8;
    self.layer.masksToBounds = YES;
    self.layer.borderWidth = 2;
    self.layer.borderColor = SQColor(@"#DFF8EF").CGColor;
    [self.contentView addSubview:self.topView];
    [self.contentView addSubview:self.nameLabel];
    [self.contentView addSubview:self.titleLabel];
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.contentView);
        make.bottom.equalTo(self.contentView.mas_bottom).offset(-22);
    }];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.contentView);
        make.bottom.equalTo(self.contentView.mas_bottom).offset(-46);
    }];
    [self.topView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self.contentView);
            make.centerY.equalTo(self.contentView.mas_centerY).offset(-30);
    }];
}
- (void)setModel:(HotModel *)model{
    if (model.isSeleted) {
        self.layer.borderColor = SQColor(@"#4AF8CE").CGColor;
    } else {
        self.layer.borderColor = SQColor(@"#DFF8EF").CGColor;
    }
    self.nameLabel.text = model.name;
    self.titleLabel.text = model.title;
    [self.topView mas_updateConstraints:^(MASConstraintMaker *make) {
            make.width.mas_equalTo(model.width);
            make.height.mas_equalTo(model.height);
    }];
}
- (UIView *)topView{
    if (!_topView) {
        _topView = [[UIView alloc]init];
        _topView.backgroundColor = UIColor.blackColor;
    }
    return _topView;
}
- (UILabel *)titleLabel{
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc]init];
        _titleLabel.font = FONT_REGULAR(14);
        _titleLabel.textColor = SQColor333333;
        _titleLabel.textAlignment = NSTextAlignmentCenter;
        _titleLabel.backgroundColor = UIColor.clearColor;
    }
    return _titleLabel;
}
- (UILabel *)nameLabel{
    if (!_nameLabel) {
        _nameLabel = [[UILabel alloc]init];
        _nameLabel.font = FONT_REGULAR(14);
        _nameLabel.textColor = SQColor333333;
        _nameLabel.textAlignment = NSTextAlignmentCenter;
        _nameLabel.backgroundColor = UIColor.clearColor;
    }
    return _nameLabel;
}
 
@end
